# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Fabian Schoelzel <myfirstname.mylastname@googlemail.com>
# Contributor: funkyou <spamopfer@nickname.berlin.de>
# Contributor: tardo <tardo@nagi-fanboi.net>
# Contributor: Stefan Husmann <stefan-husmann@t-online.de>
# Contributor: Gustavo Alvarez <sl1pkn07@gmail.com>

pkgbase=mlt
pkgname=(mlt mlt-python-bindings)
pkgver=6.10.0
pkgrel=1
pkgdesc="An open source multimedia framework"
arch=(x86_64)
url="http://www.mltframework.org"
license=(GPL)
makedepends=(ladspa frei0r-plugins libdv sdl_image libsamplerate sox ffmpeg vid.stab qt5-svg
             jack libexif python2 swig movit eigen opencv libebur128 gtk2)
source=($pkgname-$pkgver.tar.gz::"https://github.com/mltframework/mlt/archive/v$pkgver.tar.gz")
sha256sums=('e794f12b00d1b90009a1574237823a03ce0b3625638306d1369888375e90edff')

build() {
  # mlt
  cd mlt-$pkgver

  ./configure --prefix=/usr \
	--avformat-swscale \
	--enable-gpl --enable-gpl3 \
	--qt-libdir=/usr/lib --qt-includedir=/usr/include/qt
  make

  # mlt python bindings
  cd src/swig/python
  sed -i 's_path=`which python_path=`which python2_' build
  sed -i 's_`python -c_`python2 -c_' build
  sed -i 's#python-config#python2-config#' build
  ./build
}

package_mlt() {
  depends=(libebur128)
  optdepends=('sdl_image: SDL1 plugin'
        'sdl2: SDL2 plugin'
        'libsamplerate: libavresample plugin'
        'sox: SOX (Audio Swiss Army Knife) plugin'
        'ffmpeg: ffmpeg plugin'
        'vid.stab: video stabilize plugin'
        'gtk2: Gtk plugin'
        'qt5-svg: Qt5 plugins'
        'jack: JACK sound output plugin'
        'ladspa: LADSPA plugins'
        'libexif: auto rotate plugin'
        'frei0r-plugins: for additional effects'
        'movit: opengl plugin'
        'opencv: openCV plugin')

  cd mlt-$pkgver
  make DESTDIR="$pkgdir" install
}

package_mlt-python-bindings() {
  depends=(python2 mlt)

  cd "$srcdir/mlt-$pkgver/src/swig/python"
  mkdir -p "$pkgdir/usr/lib/python2.7/"
  install -m755 mlt.py "$pkgdir/usr/lib/python2.7/"
  install -m755 _mlt.so "$pkgdir/usr/lib/python2.7/"
  install -m755 mlt_wrap.o "$pkgdir/usr/lib/python2.7/"
}
